home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / cstwnd / blocks.cpp < prev    next >
C/C++ Source or Header  |  1993-12-20  |  4KB  |  152 lines

  1. #include "blocks.h"
  2. #include <windowsx.h>
  3.  
  4. /*******************************************************************
  5. NOTE:    Although the code for this class is provided if
  6. you wish to change it you chouls change the name because
  7. it is also in the DLL and LIB under the same name and
  8. can be used as is.
  9. *******************************************************************/
  10.  
  11. void TBlockWindows::UCtlColor(RTMessage Msg)
  12. {
  13.     TUnderlying::UCtlColor(Msg);
  14.  
  15.     if(Chars.CustomLevel < 1)
  16.         return;
  17.         //DefWindowProc would have been called by
  18.         //TUnderlying
  19.  
  20. /*******************************************************************
  21. It looked really nice when this was done for all controls
  22. not just the static controls, unfortunately the backrougn
  23. never gets erased and many of the controls can't be
  24. changed then.
  25. ******************************************************************/
  26.     switch(Msg.LP.Hi)
  27.         {
  28.         case CTLCOLOR_STATIC:
  29.             SetBkMode((HDC)Msg.WParam,NULL);
  30.             SetWindowLong(MyHWindow, DWL_MSGRESULT, (LRESULT)GetStockBrush(HOLLOW_BRUSH));
  31.             Msg.Result = (LRESULT)GetStockBrush(NULL_BRUSH);
  32.             break;
  33.       }
  34. }
  35.  
  36. void TBlockWindows::UEraseBkGnd(RTMessage Msg)
  37. {
  38.     if(Chars.CustomLevel < 1)
  39.         {
  40.       TUnderlying::UEraseBkGnd(Msg);
  41.         return;
  42.         }
  43.  
  44.     HBRUSH Fill1,Fill2,OldB;
  45.     Fill1 = CreateSolidBrush(DrawColors.UpLeftBorders);
  46.     Fill2 = CreateSolidBrush(DrawColors.RightBottomBorders);
  47.  
  48.     OldB = SelectBrush((HDC)Msg.WParam,Fill1);
  49.     HPEN OldP = SelectPen((HDC)Msg.WParam,GetStockPen(NULL_PEN));
  50.  
  51.     RECT ClientArea;
  52.    GetWindowRect(MyHWindow,&ClientArea);
  53.  
  54.     Rectangle((HDC)Msg.WParam,0,0,
  55.         ClientArea.right,ClientArea.bottom);
  56.  
  57.    SelectBrush((HDC)Msg.WParam,Fill2);
  58.     for(int x=0;x<=ClientArea.right+8;x+=ClientArea.right/8)
  59.         for(int y=0;y<=ClientArea.bottom+8;y+=ClientArea.bottom/8)
  60.             {
  61.             Rectangle((HDC)Msg.WParam,x,y,
  62.                 x+ClientArea.right/16,
  63.                 y+ClientArea.bottom/16);
  64.             Rectangle((HDC)Msg.WParam,x+ClientArea.right/16,
  65.                 y+ClientArea.bottom/16,
  66.                 x+ClientArea.right/8,
  67.                 y+ClientArea.bottom/8);
  68.             }
  69.  
  70.     SelectPen((HDC)Msg.WParam,OldP);
  71.     SelectBrush((HDC)Msg.WParam,OldB);
  72.  
  73.     DeleteBrush(Fill1);
  74.    DeleteBrush(Fill2);
  75. }
  76.  
  77. void TBlockWindows::UserFrame(HDC DrawDC)
  78. {
  79.     HPEN Out = CreatePen(PS_SOLID, 1, DrawColors.WindowBack);
  80.     HPEN OldP;
  81.  
  82.     HBRUSH Fill1,Fill2;
  83.     Fill1 = CreateSolidBrush(DrawColors.UpLeftBorders);
  84.     Fill2 = CreateSolidBrush(DrawColors.RightBottomBorders);
  85.  
  86.     HBRUSH OldB = SelectBrush(DrawDC, Fill2);
  87.     OldP = SelectPen(DrawDC, GetStockPen(NULL_PEN));
  88.  
  89.     Rectangle(DrawDC, WindowRect.left, WindowRect.top,
  90.        WindowRect.right+1, WindowRect.bottom+1);
  91.  
  92.     SelectPen(DrawDC, Out);
  93.    SelectBrush(DrawDC, Fill1);
  94.  
  95.     for(int x=0;x<=WindowRect.right+8;x+=WindowRect.right/4)
  96.         for(int y=0;y<=WindowRect.bottom+8;y+=WindowRect.bottom/4)
  97.             {
  98.             Rectangle(DrawDC,x,y,
  99.                 x+WindowRect.right/8,
  100.                 y+WindowRect.bottom/8);
  101.             }
  102.  
  103.     SelectPen(DrawDC, OldP);
  104.     SelectBrush(DrawDC,OldB);
  105.  
  106.     DeletePen(Out);
  107.     DeleteBrush(Fill1);
  108.    DeleteBrush(Fill2);
  109. }
  110.  
  111. void TBlockWindows::UserTitle(HDC DrawDC)
  112. {
  113.  
  114.     HBRUSH Fill;
  115.     if(Chars.IsActive)
  116.         {
  117.         SetTextColor(DrawDC,DrawColors.TitleTextActive);
  118.         Fill = CreateSolidBrush(DrawColors.TitleBarActive);
  119.       }
  120.     else
  121.       {
  122.         SetTextColor(DrawDC,DrawColors.TitleTextInactive);
  123.         Fill = CreateSolidBrush(DrawColors.TitleBarInactive);
  124.         }
  125.  
  126.     HBRUSH OldB = SelectBrush(DrawDC, Fill);
  127.  
  128.     HPEN OldP = SelectPen(DrawDC, GetStockPen(BLACK_PEN));
  129.  
  130.     for(float x=TitleRect.left;x<=TitleRect.right;
  131.             x+=(float)(TitleRect.right-TitleRect.left)/8.00)
  132.             Rectangle(DrawDC, x,TitleRect.top,x+
  133.                 (((float)(TitleRect.right-TitleRect.left)/8.00 >
  134.                 TitleRect.right) ? TitleRect.right :
  135.                 (float)(TitleRect.right-TitleRect.left)/8.00),
  136.                 TitleRect.bottom);
  137.  
  138.     SetBkMode(DrawDC,TRANSPARENT);
  139.     SetTextAlign(DrawDC,TA_RIGHT);
  140.  
  141.     char Text[80];
  142.     GetWindowText( MyHWindow, Text, 79 );
  143.  
  144.     TextOut(DrawDC, TitleRect.right - BitWidth*2,
  145.         TitleRect.top + 1, Text, lstrlen(Text));
  146.  
  147.     SelectPen(DrawDC, OldP);
  148.     SelectBrush(DrawDC, OldB);
  149.  
  150.     DeleteBrush(Fill);
  151. }
  152.